/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.transas.zorlog.ui.graph;

import java.awt.Color;

/**
 *
 * @author amalikov
 */
class AutoColor {
	public AutoColor(float hue0, float dhue, float brightness0, float dbrightness) {
		this.hue0 = hue0;
		this.dhue = dhue;
		this.brightness0 = brightness0;
		this.dbrightness = dbrightness;
		init();
	}
	
	public final void init() {
		hue = hue0;
		brightness = brightness0;
	}
	
	public Color get() {
		return Color.getHSBColor(hue, 1.0f, brightness);
	}

	public void next() {
		brightness *= dbrightness;
		hue += dhue;
		if (hue > 1.0f)
			hue -= 1.0f;
		else if (hue < -1.0f)
			hue += 1.0f;
	}
	
	public void set(Color color) {
		float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null);
		hue = hsb[0];
		brightness = hsb[2];
	}
	
	private float hue0;
	private float hue;
	private final float dhue;
	private float brightness0;
	private float brightness;
	private final float dbrightness;
}
